export const isEmpty = (value: any) =>
  value === null
  || value === undefined
  || Number.isNaN(value)
  || value === ''
  || value === 0;

// 通用的过滤空值函数
export const filterEmptyValues = (
  obj: Record<
    string,
    | string
    | number
    | boolean
    | Record<string, string | null | undefined | number>
    | undefined
    | null
  >,
): any => {
  for (const key in obj) {
    const currentValue = obj[key];
    if (isEmpty(currentValue) && key !== 'sex') {
      delete obj[key];
      continue
    }
    // 如果是对象，递归处理
    if (typeof currentValue === 'object') {
      if (!Object.keys(currentValue as Record<string, any>).length) {
        delete obj[key];
        continue
      }
      filterEmptyValues(currentValue as Record<string, any>);
    }
  }

  return obj;
}
